<?php
namespace User\Model\Entity;

use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;

use Zend\Form\Annotation;

class User implements InputFilterAwareInterface
{
	protected $inputFilter;
	
	protected $_id;

	protected $_username;

	protected $_password;

 	protected $_first_name;

 	protected $_middle_name;

	protected $_last_name;
	
	protected $_dob;
	
	protected $_email;
	
	protected $_avatar;
	
	protected $_phone;
	
	protected $_created_date;
	
	protected $_state;
	
	protected $_display_name;
	
	public function exchangeArray($data)
	{
		$this->_id 			= (isset($data['id']) 			&& $data['id'] != '' ) ? $data['id'] : null;
		$this->_username 	= (isset($data['username']) 	&& $data['username'] != ''  ) ? $data['username'] : null;
		$this->_email 		= (isset($data['email']) 		&& $data['email'] != '' ) ? $data['email'] : null;
		$this->_password 	= (isset($data['password']) 	&& $data['password'] != '' ) ? $data['password'] : null;
		$this->_first_name 	= (isset($data['first_name'])	&& $data['first_name'] != '' ) ? $data['first_name'] : null;
		$this->_middle_name = (isset($data['middle_name'])	&& $data['middle_name'] != '' ) ? $data['middle_name'] : null;
		$this->_last_name 	= (isset($data['last_name'])	&& $data['last_name'] != '' ) ? $data['last_name'] : null;
		$this->_dob 		= (isset($data['dob'])			&& $data['dob'] != '' ) ? $data['dob'] : null;
		$this->_avatar 		= (isset($data['avatar'])		&& $data['avatar'] != '' ) ? $data['avatar'] : null;
		$this->_phone 		= (isset($data['phone'])		&& $data['phone'] != '' ) ? $data['phone'] : null;
		$this->_state 		= (isset($data['state'])		&& $data['state'] != '' ) ? $data['state'] : null;
		$this->_created_date = (isset($data['created_date'])&& $data['created_date'] != '' ) ? $data['created_date'] : null;
		
	}
	
	/**
	 * @return the $_id
	 */
	public function getId() {
		return $this->_id;
	}

	/**
	 * @return the $_first_name
	 */
	public function getFirst_name() {
		return $this->_first_name;
	}

	/**
	 * @return the $_middle_name
	 */
	public function getMiddle_name() {
		return $this->_middle_name;
	}

	/**
	 * @return the $_last_name
	 */
	public function getLast_name() {
		return $this->_last_name;
	}

	/**
	 * @return the $_dob
	 */
	public function getDob() {
		return $this->_dob;
	}

	/**
	 * @return the $_avatar
	 */
	public function getAvatar() {
		return $this->_avatar;
	}

	/**
	 * @return the $_phone
	 */
	public function getPhone() {
		return $this->_phone;
	}

	/**
	 * @return the $_created_date
	 */
	public function getCreated_date() {
		return $this->_created_date;
	}



	/**
	 * @return the $_username
	 */
	public function getUsername() {
		return $this->_username;
	}

	/**
	 * @return the $_email
	 */
	public function getEmail() {
		return $this->_email;
	}

	/**
	 * @return the $_display_name
	 */
	public function getDisplay_name() {
		
		if(!$this->_display_name) 
		{
			$this->_display_name = $this->_last_name . ' ' . $this->_middle_name . ' ' . $this->_first_name;
		}
		
		return $this->_display_name;
	}

	/**
	 * @return the $_password
	 */
	public function getPassword() {
		return $this->_password;
	}

	/**
	 * @return the $_state
	 */
	public function getState() {
		return $this->_state;
	}
	/**
	 * @param Ambigous <NULL, unknown> $_id
	 */
	public function setId($_id) {
		$this->_id = $_id;
	}
	
	/**
	 * @param Ambigous <NULL, unknown> $_first_name
	 */
	public function setFirst_name($_first_name) {
		$this->_first_name = $_first_name;
	}
	
	/**
	 * @param Ambigous <NULL, unknown> $_middle_name
	 */
	public function setMiddle_name($_middle_name) {
		$this->_middle_name = $_middle_name;
	}
	
	/**
	 * @param Ambigous <NULL, unknown> $_last_name
	 */
	public function setLast_name($_last_name) {
		$this->_last_name = $_last_name;
	}
	
	/**
	 * @param Ambigous <NULL, unknown> $_dob
	 */
	public function setDob($_dob) {
		$this->_dob = $_dob;
	}
	
	/**
	 * @param Ambigous <NULL, unknown> $_avatar
	 */
	public function setAvatar($_avatar) {
		$this->_avatar = $_avatar;
	}
	
	/**
	 * @param Ambigous <NULL, unknown> $_phone
	 */
	public function setPhone($_phone) {
		$this->_phone = $_phone;
	}

	/**
	 * @param Ambigous <NULL, unknown> $_username
	 */
	public function setUsername($_username) {
		$this->_username = $_username;
	}

	/**
	 * @param Ambigous <NULL, unknown> $_email
	 */
	public function setEmail($_email) {
		$this->_email = $_email;
	}

	/**
	 * @param Ambigous <NULL, unknown> $_password
	 */
	public function setPassword($_password) {
		$this->_password = $_password;
	}

	/**
	 * @param Ambigous <NULL, unknown> $_state
	 */
	public function setState($_state) {
		$this->_state = $_state;
	}

	
	public function setInputFilter(InputFilterInterface $inputFilter)
	{
		throw new \Exception("Not implement");
	}
	
	
	public function getInputFilter()
	{
		if(!$this->inputFilter)
		{
			$inputFilter = new InputFilter();
			$factory = new InputFactory();
			
			
			$inputFilter->add($factory->createInput(array(
						'name'     => 'username',
						'required' => true,
						'filters'  => array(
								array('name' => 'StripTags'),
								array('name' => 'StringTrim'),
						),
						'validators' => array(
								array(
										'name'    => 'StringLength',
										'options' => array(
												'encoding' => 'UTF-8',
												'min'      => 5,
												'max'      => 255,
										),
								),
						),
					)));
			$inputFilter->add($factory->createInput(array(
						'name'     => 'email',
						'validators' => array(
								array(
										'name'    => 'EmailAddress'
								),
						),
					
					)));
			$inputFilter->add($factory->createInput(array(
						'name'     => 'dob',
						'validators' => array(
								array(
										'name'    => 'Between',
										'options' => array(
												'min' => '1970-01-01',
												'max' => date('Y-m-d')
										),
								),
						),
					
					)));
			$this->inputFilter = $inputFilter;
		}
		
		return $this->inputFilter;
	}
}
